"use strict";
const utils_index = require("../utils/index.js");
const common_vendor = require("../common/vendor.js");
const useGlobalMessage = common_vendor.defineStore("global-message", {
  state: () => ({
    messageOptions: null,
    currentPage: ""
  }),
  actions: {
    show(option) {
      this.currentPage = utils_index.getCurrentPath();
      this.messageOptions = {
        ...common_vendor.isString(option) ? { title: option } : option,
        cancelButtonProps: {
          round: false
        },
        confirmButtonProps: {
          round: false
        }
      };
    },
    alert(option) {
      const messageOptions = common_vendor.deepMerge({ type: "alert" }, common_vendor.isString(option) ? { title: option } : option);
      messageOptions.showCancelButton = false;
      this.show(messageOptions);
    },
    confirm(option) {
      const messageOptions = common_vendor.deepMerge({ type: "confirm" }, common_vendor.isString(option) ? { title: option } : option);
      messageOptions.showCancelButton = true;
      this.show(messageOptions);
    },
    prompt(option) {
      const messageOptions = common_vendor.deepMerge({ type: "prompt" }, common_vendor.isString(option) ? { title: option } : option);
      messageOptions.showCancelButton = true;
      this.show(messageOptions);
    },
    close() {
      this.messageOptions = null;
      this.currentPage = "";
    }
  }
});
exports.useGlobalMessage = useGlobalMessage;
